//
//  WBNavController.swift
//  weibo
//
//  Created by 李江波 on 16/10/6.
//  Copyright © 2016年 lijiangbo. All rights reserved.
//

import UIKit

class WBNavController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
       
        navigationBar.isHidden = true
        
    }

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count > 0 {
            
            viewController.hidesBottomBarWhenPushed = true
            
            if let vc = viewController as? WBBaseController {
                
                var title = "返回"
                
                if childViewControllers.count == 1 {
                    
                    title = childViewControllers.first?.title ?? ""
                }
                
                vc.navItem.leftBarButtonItem = UIBarButtonItem(title: title, target: self, action: #selector(popVc), isbackButton: true)
            }
            
        }
        
        super.pushViewController(viewController, animated: true)
    }
    
    @objc private func popVc(){
    
       popViewController(animated: true)
    
    }
    

}
